<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:zhjin="http://java.sun.com/jsf/composite/component"
	xmlns:zh="http://www.zhjin.com/custom"
	template="../template/base.xhtml">

	<ui:define name="title">
		<h:outputText value="#{windowData.windowTitle}"/>
	</ui:define>
	<ui:define name="pagecontent">
		<h:form id="form" enctype="multipart/form-data">
			<p:growl id="growl" showDetail="true" life="5000"></p:growl>
			<div style="position:absolute;top:0px;width:100%;height:26px;overflow:none;">			
		        <p:toolbar style="height:20px;padding-top:3px;">
					<p:toolbarGroup align="left" style="padding-top:0px;padding-right:10px;">
						<p:commandButton value="暂存" icon="ui-icon-locked"
							actionListener="#{wfManager.tempSave}"
							rendered="false">
						</p:commandButton>
						<p:commandButton id="wfimage" value="流程图" icon="ui-icon-image">
						</p:commandButton>
						<p:commandButton id="attachfile" value="附件(#{windowData.inData.attachFileNum})" icon="ui-icon-document">
						</p:commandButton>
					</p:toolbarGroup>
					<p:toolbarGroup align="right" style="padding-top:0px;padding-right:10px;">
						<p:commandButton value="取消" icon="ui-icon-cancel"
							onclick="if (confirm('确认取消流程申请 ( 取消操作不可恢复 ) ?') == false) return false;"
							actionListener="#{wfManager.cancelWf}"
							rendered="#{windowData.inData.requestType == 'NEW'}">
						</p:commandButton>
					</p:toolbarGroup>
				</p:toolbar>
		    </div>
		    <div style="position:absolute;width:100%;top:28px;left:1px;right:1px;bottom:0px;overflow-y:auto;padding-top:0px;">
				<div style="position:absolute;top:0px;left:0px;height:30px;right:0px;border:solid;border-color:#a6c9e2;border-width:1px;border-top:none;border-left:none;border-right:none;">
					<zh:div styleClass="dive2" style="padding-top:5px;">
						<label class="fieldLabel"><h:outputText value="标题:"/></label>
						<p:inputText value="#{windowData.inData.requireTitle}" styleClass="inpute2"
							disabled="#{windowData.inData.requestType != 'NEW'}">
						</p:inputText>
					</zh:div>
					<zh:div styleClass="dive1" style="padding-top:5px;">
						<label class="fieldLabel"><h:outputText value="紧急程度:"/></label>
						<h:selectOneMenu value="#{windowData.inData.urgentLevel}" styleClass="selectmenue1"
							disabled="#{windowData.inData.requestType != 'NEW'}">
							<f:selectItem itemValue="1" itemLabel="普通"/>
							<f:selectItem itemValue="2" itemLabel="紧急"/>
						</h:selectOneMenu>
					</zh:div>
				</div>
				<div style="position:absolute;top:31px;left:0px;bottom:0px;width:100%;overflow:auto;background-color:white;">
					<div style="width:100%;height:5px;clear:both;"></div>
					<ui:include src="#{windowData.inData.url}" />
					<div style="float:left;"></div>
					<p:panel header="提交申请" style="float:left;width:99%;" rendered="#{windowData.inData.requestType == 'NEW'}">
						<h:outputText value="流程备注信息:" style="color:#2e6e9e;" />
						<p:editor value="#{windowData.inData.wfRemark}" width="1000" height="200"
							controls="bold italic underline strikethrough font size style color highlight bullets numbering alignleft center alignright justify outdent indent">
						</p:editor>
						<p:commandButton value="提交流程申请" icon="ui-icon-check" style="margin-top:2px;"
							onclick="if (confirm('确认提交流程申请 ?') == false) return false;"
							actionListener="#{wfManager.submitWf}"
							rendered="#{windowData.inData.requestType == 'NEW'}">
						</p:commandButton>
					</p:panel>
					<p:panel header="流程备注及审批明细" style="float:left;width:99%;" rendered="#{windowData.inData.requestType != 'NEW'}"
						>						
						<h:panelGrid columns="1" style="width:100%;">
							<h:outputText value="流程备注信息:" style="color:#2e6e9e;font-weight:bold;" />
							<p:panel style="width:1000px;">
								<h:outputText value="#{windowData.inData.wfRemark}" escape="false">
								</h:outputText>
							</p:panel>
							<h:outputText value="已审批结果记录:" style="color:#2e6e9e;font-weight:bold;" />
							<p:dataTable value="#{windowData.objMap['actorHistoryList']}" var="row"
								style="width:1000px;"
								selectionMode="single"
								rowKey="#{row.rowKey}">
								<p:column headerText="流程节点">
									#{row.nodeName}
								</p:column>
								<p:column headerText="审批人" styleClass="columncenter">
									#{row.actorName}
								</p:column>
								<p:column headerText="实际审批人" styleClass="columncenter">
									#{row.realActorName}
								</p:column>
								<p:column headerText="审批结果" styleClass="columncenter">
									#{row.applyResult}
								</p:column>
								<p:column headerText="审批时间" styleClass="columncenter">
									<h:outputText value="#{row.endTime}">
										<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss"/>
									</h:outputText>
								</p:column>
								<p:column headerText="审批意见">
									<h:outputText value="#{row.applyRemark}" escape="false">
									</h:outputText>
								</p:column>
							</p:dataTable>	
						</h:panelGrid>
					</p:panel>
					<p:panel header="流程审批" style="float:left;width:99%;margin-top:1px;" 
						rendered="#{windowData.inData.requestType == 'APPLY'}">
						<h:outputText value="审批结果: " style="color:#2e6e9e;font-weight:bold;padding-left:0px;" />
						<p:selectOneButton value="#{windowData.inData.applyResult}" valueChangeListener="#{wfManager.applyResultChange}">
							<f:selectItem itemLabel="同意" itemValue="AGREE" />
							<f:selectItem itemLabel="拒绝" itemValue="DENY" />
							<f:selectItem itemLabel="已阅" itemValue="READ" />
							<f:selectItem itemLabel="回退" itemValue="ROLLBACK" />
							<p:ajax envet="change"></p:ajax>
						</p:selectOneButton>
						<h:selectOneMenu id="rollbacknodeid" value="#{windowData.inData.rollbackNodeId}"
							rendered="#{windowData.inData.applyResult == 'ROLLBACK'}">>
							<f:selectItems value="#{windowData.inData.rollbackNodeList}"></f:selectItems>
						</h:selectOneMenu>

						<p:editor value="#{windowData.inData.applyRemark}" width="1000" height="200"
							controls="bold italic underline strikethrough font size style color highlight bullets numbering alignleft center alignright justify outdent indent">
						</p:editor>
						<p:commandButton value="提交审批结果" icon="ui-icon-check" style="margin-top:2px;"
							actionListener="#{wfManager.applyWorkflow}">
						</p:commandButton>
					</p:panel>
				</div>	    	
		    </div>
		</h:form>
		<p:overlayPanel id="filepanel" for="form:attachfile" hideEffect="fade" style="width:500px;" >
			<h:form id="abc" enctype="multipart/form-data">
				<p:dataTable id="filelisttable" style="width:100%;" value="#{windowData.inData.attachFileList}" 
					emptyMessage="" var="row" editable="true">
					<p:column headerText="删除" style="width:20px;" styleClass="columncenter"
						rendered="#{windowData.inData.requestType == 'NEW'}">
						<p:commandLink styleClass="ui-icon ui-icon-trash"
							actionListener="#{wfManager.deleteAttachFile}"
							onclick="if (confirm('确认删除所选附件( #{row.fileName} )?') == false) return false;"
							>
							<f:attribute name="fileId" value="#{row.id}"></f:attribute>
						</p:commandLink>
					</p:column>
					<p:column headerText="编辑"
						rendered="#{windowData.inData.requestType == 'NEW'}">
						<p:rowEditor>
						</p:rowEditor>
					</p:column>
					<p:column headerText="文件名">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{row.fileName}"/>
							</f:facet>
							<f:facet name="input">
								<p:inputText value="#{row.fileName}"
									valueChangeListener="#{wfManager.fileNameChange}" 
									style="border:0px; text-align:left; width:260px;">
									<f:attribute name="fileId" value="#{row.id}"></f:attribute>
									<p:ajax event="change"></p:ajax>
								</p:inputText>
							</f:facet>
						</p:cellEditor>	
					</p:column>
					<p:column headerText="文件大小(字节)" styleClass="columnright">
						<h:outputText value="#{row.fileSize}">
							<f:convertNumber pattern="##,##0"/>
						</h:outputText>
					</p:column>
					<p:column headerText="下载" styleClass="columncenter">
						<p:commandLink actionListener="#{wfManager.downloadAttachFile}" styleClass="ui-icon ui-icon-arrowthick-1-s"
							ajax="false">
							<f:attribute name="fileId" value="#{row.id}"></f:attribute>
						</p:commandLink>
					</p:column>
				</p:dataTable>
				<p:fileUpload label="选择文件" 
					uploadLabel="上传" showButtons="false"
					mode="advanced"
					style="padding-top:3px;"
					fileUploadListener="#{wfManager.uploadAttachFile}"
					auto="true"
					rendered="#{windowData.inData.requestType == 'NEW'}">
				</p:fileUpload>
			</h:form>
		</p:overlayPanel>
		<p:overlayPanel for="form:wfimage" hideEffect="fade" dynamic="true">
			<div style="margin:0px;padding:0px;overflow:auto;width:900px;height:600px;">
				<img src="#{request.contextPath}/workflow/showworkflowimage?wfid=#{windowData.objMap['wfid']}&amp;instanceId=#{windowData.inData.wfInstanceId}" />				
			</div>
		</p:overlayPanel>
	</ui:define>
</ui:composition>